/**
 * Copyright HCP Technology 
 * www.hcp.vn
 */
package models;

import java.util.Date;
import java.util.List;

import siena.Id;
import siena.Index;
import siena.Model;
import siena.Query;

public class FollowModel extends Model{

		@Id
		public Long id;
		@Index("user_follow_content")
		public String user;
		public Long id_content;
		public String title_content;
		public String alias_content;
		public Date date;
		
		public FollowModel(String user, Long id_content, String tiile_content, String alias_content) {
			super();
			this.user = user;
			this.id_content = id_content;
			this.title_content = tiile_content;
			this.alias_content = alias_content;
			this.date = new Date();
		}
		
		static Query<FollowModel> all(){
			return Model.all(FollowModel.class);
		}
		
		public static List<FollowModel> followContentsByUser(String user){
			return all().filter("user", user).fetch();
		}
		
		public static void deleteFollowContent(Long id){
			try {
				all().getByKey(id).delete();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	
		
}
